package org.xc.uvc_camera;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.ReplacementTransformationMethod;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class PlateNumberActivity extends AppCompatActivity {

    public static void launcher(Context context) {
        context.startActivity(new Intent(context,PlateNumberActivity.class));
    }

    private EditText et_platenumber;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_platenumber);

        et_platenumber = (EditText) findViewById(R.id.et_platenumber);

        et_platenumber.setTransformationMethod(new ReplacementTransformationMethod() {
            @Override
            protected char[] getOriginal() {
                char[] originalCharArr = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
                return originalCharArr;
            }

            @Override
            protected char[] getReplacement() {
                char[] replacementCharArr = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
                return replacementCharArr;
            }
        });


        findViewById(R.id.btn_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String plateNumber = et_platenumber.getText().toString();
                if (TextUtils.isEmpty(plateNumber)) {
                    return;
                }
                SPUtil.write(PlateNumberActivity.this,"plate_number",plateNumber);
                Toast.makeText(PlateNumberActivity.this,"保存成功",Toast.LENGTH_SHORT).show();
                finish();
            }
        });
    }
}
